<?php
class Font_Model_Pages extends Zend_Db_Table{
	protected $_name = 'pages';
	protected $_primary = 'id';


	public function getAll($arrParam = 1,$order='desc'){
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		      ->from("pages")
		      ->where("id_cate = ?",$arrParam);
		if( $order != "desc")
			$select=$select ->order("time_create");
		else
			$select=$select ->order("time_create desc");
		
		return $db->fetchAll($select);
	}
	
	public function  addPage($arrParam){
		$row =  $this->fetchNew();
		$row->title   		= $arrParam['title'];
 		$row->time			= $arrParam['time'];
 		$row->location 		= $arrParam['location'];
  		$row->image 		= $arrParam['image'];
		$row->content 		= $arrParam['content'];
		$row->contact 		= $arrParam['contact'];
		$row->phone 		= $arrParam['phone'];
		$row->email 		= $arrParam['email'];
		$row->id_cate 		= $arrParam['id_cate'];
 		$row->description 	= $arrParam['description'];
 		$row->timestudy 	= $arrParam['timestudy'];
		$row->cost 	= $arrParam['cost'];
 		$row->time_create	= date("Y-m-d H:i:s"); 
		$row->save();
		
	}

	public function getPage($arrParam ){
		$se = $this->select();
		$se->where("id= ?",$arrParam['id']);
		return $this->fetchRow($se);
	
	}


}